<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SinusoidalSteering</title>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] },
  TeX: { equationNumbers: { autoNumber: 'all' } }
});
</script>
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
body > * {
  max-width: 1000px;
}
body {
  font-family: "Roboto Condensed", sans-serif;
  padding-left: 7.5em;
  padding-right: 7.5em;
}
pre, code {
  max-width: 60em;
  font-family: monospace;
}
pre.oct-code {
  border: 1px solid Grey;
  padding: 5px;
}
pre.oct-code-output {
  margin-left: 2em;
}
span.comment {
  color: ForestGreen;
}
span.keyword {
  color: Blue;
}
span.string {
  color: DarkOrchid;
}
footer {
  margin-top: 2em;
  font-size: 80%;
}
a, a:visited {
  color: Blue;
}
h2 {
  font-family: "Roboto Condensed", serif;
  margin-top: 1.5em;
}
h2 a, h2 a:visited {
  color: Black;
}
</style>
</head>
<body>
<p><b>Defining parameters</b></p><pre class="oct-code"><span class="comment">% Choosing simulation</span>
T = 4;                              <span class="comment">% Total simulation time [s]</span>
resol = 50;                         <span class="comment">% Resolution</span>
TSPAN = 0:T/resol:T;                <span class="comment">% Time span [s]</span>

<span class="comment">% Choosing tire</span>
TireModel = TirePacejka();
<span class="comment">% Choosing vehicle</span>
System = VehicleSimpleNonlinear();

<span class="comment">% Steering angle</span>
System.deltaf = 1*pi/180*sin(T^-1*2*pi*TSPAN);
<span class="comment">% Tire model</span>
System.tire = TireModel;
System.muy = 1.0;


simulator = Simulator(System, TSPAN);</pre><p><b>Run simulation</b></p><pre class="oct-code">simulator.Simulate();</pre><p><b>Results</b></p><pre class="oct-code"><span class="comment">% Retrieving states</span>
XT = simulator.XT;
YT = simulator.YT;
PSI = simulator.PSI;
VEL = simulator.VEL;
ALPHAT = simulator.ALPHAT;
dPSI = simulator.dPSI;

f1 = figure(1);
grid on ; box on;
plot(TSPAN,180/pi*System.deltaf)
xlabel(<span class="string">'time [s]'</span>)
ylabel(<span class="string">'Steering angle [deg]'</span>)</pre><img width="500" src="../illustrations/plot/SinusoidalSteeringFig1.svg" alt="../illustrations/plot/SinusoidalSteeringFig1.svg"><p>Frame and animation</p><pre class="oct-code">g = Graphics(simulator);
g.TractorColor = <span class="string">'r'</span>;

g.Frame(<span class="string">'scalefig'</span>,3);</pre><img width="800" src="../illustrations/frame/SinusoidalSteeringFrame.svg" alt="../illustrations/frame/SinusoidalSteeringFrame.svg"><pre class="oct-code">g.Animation(<span class="string">'scalefig'</span>,3);</pre><img src="../illustrations/animation/SinusoidalSteeringAnimation.gif" alt="../illustrations/animation/SinusoidalSteeringAnimation.gif">
<footer><hr><a href="http://www.octave.org">Published with GNU Octave 4.2.1</a></footer>
<!--
##### SOURCE BEGIN #####
%%
% *Defining parameters*

% Choosing simulation
T = 4;                              % Total simulation time [s]
resol = 50;                         % Resolution
TSPAN = 0:T/resol:T;                % Time span [s]

% Choosing tire
TireModel = TirePacejka();
% Choosing vehicle
System = VehicleSimpleNonlinear();

% Steering angle
System.deltaf = 1*pi/180*sin(T^-1*2*pi*TSPAN);
% Tire model
System.tire = TireModel;
System.muy = 1.0;


simulator = Simulator(System, TSPAN);

%%
% *Run simulation*
%

simulator.Simulate();

%%
% *Results*
%

% Retrieving states
XT = simulator.XT;
YT = simulator.YT;
PSI = simulator.PSI;
VEL = simulator.VEL;
ALPHAT = simulator.ALPHAT;
dPSI = simulator.dPSI;

f1 = figure(1);
grid on ; box on;
plot(TSPAN,180/pi*System.deltaf)
xlabel('time [s]')
ylabel('Steering angle [deg]')

%%
% <<../illustrations/plot/SinusoidalSteeringFig1.svg>>
%

%%
% Frame and animation

g = Graphics(simulator);
g.TractorColor = 'r';

g.Frame('scalefig',3);

%%
% <<../illustrations/frame/SinusoidalSteeringFrame.svg>>
%

g.Animation('scalefig',3);

%%
% <<../illustrations/animation/SinusoidalSteeringAnimation.gif>>
%
##### SOURCE END #####
-->
</body>
</html>
